const fs = require('fs');

function readFile(filePath) {
    return new Promise((resolve, reject) => {
        fs.readFile(filePath, 'utf8', (err, data) => {
            if (err) {
                reject(err);
            } else {
                resolve(data);
            }
        });
    });
}

/* 面试题：记住 在javascript里面如果遇到异步不会等待，跳过，先去执行同步 */
;
async function go() {
    console.log('go start');

    let dataA = await readFile('./data/1.txt');
    console.log('read A end');

    let dataB = await readFile('./data/2.txt');
    let dataC = await readFile('./data/3.txt');
    console.log(dataA, dataB, dataC);

}

console.log('start');

go();

console.log('end');